package com.domi.controller;

import com.domi.bean.RestfulResponse;
import com.domi.bean.RestfulResponse.ResponseCode;
import com.domi.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@RestController
@RequestMapping("/book-client")
public class BookClientController {

    @Autowired
    private BookService bookService;

    @GetMapping("/search/{qryStr}")
    public RestfulResponse search(@PathVariable String qryStr) {
        return bookService.search(qryStr);
    }

    @GetMapping("/categories")
    public RestfulResponse categories() {
        return bookService.categories();
    }

    @GetMapping("/category/{name}")
    public RestfulResponse category(@PathVariable String name) {
        return bookService.category(name);
    }

    @GetMapping("/flight")
    public RestfulResponse flight() {
        return bookService.flight();
    }

    @GetMapping("/block")
    public RestfulResponse block() {
        return RestfulResponse.create(ResponseCode.ERROR, "服务限流", "兜底数据");
    }

}